package com.lcf.app.mongodb.model;

import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.FieldType;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.io.Serializable;
import java.time.LocalDate;

/**
 * @author ChenFei
 * @date 2021/12/3
 */
@Data
@Accessors(chain = true)
//添加：数据保存到mongodb_user集合，不加：数据保存到user集合
@Document("mongodb_user")
public class User implements Serializable {

    /**
     * 会自动生成ID，不用添加注解
     */
    private String id;

    /**
     * 不会生成Id，需要添加注解
     */
    //@MongoId
    //private String userId;

    //@Indexed ：索引
    //@Indexed(unique = true)唯一索引
    private String name;

    @Field(name = "age")//代表一个字段,可以不加
    private Integer age;

    private LocalDate birthday;

    private Double weight;

    private Double height;
}
